import request from '@/router/axios';
import {downloadExcel} from '@/router/axios';
import {formatCondition} from '@/util/util';
//单条查询
export const querySysMenu = (params) => {
  params.head.transCode = 'querySysMenu';
  return request({
    url: '/platform/sysMenu/querySysMenu',
    method: 'post',
    data: params
  })
}
//多条列表查询，支持条件查询
export const querySysMenuListPage = (params) => {
  params.head.transCode = 'querySysMenuListPage';
  return request({
    url: '/platform/sysMenu/querySysMenuListPage',
    method: 'post',
    data: params
  })
}
//获取机构下的菜单列表
export const querySysMenuListByTenantId = (params) => {
  params.head.transCode = 'querySysMenuListByTenantId';
  return request({
    url: '/platform/sysMenu/querySysMenuListByTenantId',
    method: 'post',
    data: params
  })
}
//查询菜单树
export const querySysMenuTree = (params) => {
  params.head.transCode = 'querySysMenuTree';
  return request({
    url: '/platform/sysMenu/querySysMenuTree',
    method: 'post',
    data: params
  })
}
//查询当前登录用户的菜单树
export const querySysMenuTreeByUserId = (params) => {
  params.head.transCode = 'querySysMenuTreeByUserId';
  return request({
    url: '/platform/sysMenu/querySysMenuTreeByUserId',
    method: 'post',
    data: params
  })
}
//查询当前登录用户的项目菜单树
export const querySysMenuTreeByUserIdAndProject = (params) => {
  params.head.transCode = 'querySysMenuTreeByUserIdAndProject';
  return request({
    url: '/platform/sysMenu/querySysMenuTreeByUserIdAndProject',
    method: 'post',
    data: params
  })
}
//查询当前登录用户的菜单树
export const querySysButtonByUserId = (params) => {
  params.head.transCode = 'querySysButtonByUserId';
  return request({
    url: '/platform/sysMenu/querySysButtonByUserId',
    method: 'post',
    data: params
  })
}
//新增单条记录 querySysMenuTreeByUserId
export const saveSysMenu = (params) => {
  params.head.transCode = 'saveSysMenu';
  return request({
    url: '/platform/sysMenu/saveSysMenu',
    method: 'post',
    data: params
  })
}
//新增多条记录
export const saveSysMenuList = (params) => {
  params.head.transCode = 'saveSysMenuList';
  return request({
    url: '/platform/sysMenu/saveSysMenuList',
    method: 'post',
    data: params
  })
}
//新增或修改单条记录
export const saveOrUpdateSysMenu = (params) => {
  params.head.transCode = 'saveOrUpdateSysMenu';
  return request({
    url: '/platform/sysMenu/saveOrUpdateSysMenu',
    method: 'post',
    data: params
  })
}


//新增或修改单条记录
export const saveOrUpdateSysMenuList = (params) => {
  params.head.transCode = 'saveOrUpdateSysMenuList';
  return request({
    url: '/platform/sysMenu/saveOrUpdateSysMenuList',
    method: 'post',
    data: params
  })
}

//修改单条记录
export const updateSysMenu = (params) => {
  params.head.transCode = 'updateSysMenu';
  return request({
    url: '/platform/sysMenu/updateSysMenu',
    method: 'post',
    data: params
  })
}

//删除单条记录
export const deleteSysMenu = (params) => {
  params.head.transCode = 'deleteSysMenu';
  return request({
    url: '/platform/sysMenu/deleteSysMenu',
    method: 'post',
    data: params
  })
}

//删除多条记录
export const deleteSysMenuList = (params) => {
  params.head.transCode = 'deleteSysMenuList';
  return request({
    url: '/platform/sysMenu/deleteSysMenuList',
    method: 'post',
    data: params
  })
}
//导出excel
export const exportSysMenuExcel = (params) => {
  downloadExcel({
    url: '/platform/sysMenu/excelDownload/exportSysMenuExcel',
    method: 'get',
    data: 
    {
      tenantId: params.head.tenantId,
      orders:'',
      condition: formatCondition(params.body.sqlCondition)
    }
  })
}
//同步菜单到租户
export const synchronizeSysMenu = (params) => {
  params.head.transCode = 'synchronizeSysMenu';
  return request({
    url: '/platform/sysMenu/synchronizeSysMenu',
    method: 'post',
    data: params
  })
}